#include<bits/stdc++.h>
using namespace std;

int n,r[100005];
priority_queue<int,vector<int>,greater<int> > pq;
int main(){
    freopen("duel3.in","r",stdin);
    //freopen("duel.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&r[i]);
    sort(r+1,r+n+1);
    pq.push(r[n]);
    for(int i=1;i<=n;i++){
        cout<<r[i]<<' ';
        int tmp=pq.top();
        if(tmp<r[i])pq.pop();
        pq.push(r[i]);
    }
    cout<<pq.size()-1;
}
